Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds api_version property, adds 'Accept-Version' to headers #512

Merged
merged 3 commits into from
Dec 16, 2020

Conversation

brownj85
Copy link
Collaborator

@brownj85 brownj85 commented Dec 15, 2020

Context:
The Xanadu platform API will soon be implementing versioning, allowing clients to
request a particular version of the API using the 'Accept-Version' HTTP header. This header will eventually be mandatory.

Description of the Change:
Adds an api_version str property to Connection with the value 1.0.0. On init, adds
'Accept-Version' header to Connection._headers with the value of api_version.

Benefits:
Future releases of sf will be able to use the platform API once versioning becomes
mandatory. Platform will be able to support older versions of sf following breaking
API changes.

Possible Drawbacks:
None, beyond the established drawbacks of versioning the platform API - older
releases of sf will eventually be incompatible with the platform once versioning
becomes mandatory. The current (non-versioned) platform API's behavior is
unchanged by the 'Accept-Version' header.

Related GitHub Issues:

@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #512 (581ee53) into master (bbae4bd) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #512   +/-   ##
=======================================
  Coverage   97.85%   97.85%           
=======================================
  Files          71       71           
  Lines        7406     7409    +3     
=======================================
+ Hits         7247     7250    +3     
  Misses        159      159           
Impacted Files Coverage Δ
strawberryfields/api/connection.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbae4bd...581ee53. Read the comment docs.

@brownj85 brownj85 marked this pull request as ready for review December 15, 2020 21:22
Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @brownj85!

.github/CHANGELOG.md Outdated Show resolved Hide resolved
strawberryfields/api/connection.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jswinarton jswinarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@brownj85 brownj85 merged commit 5fa114d into master Dec 16, 2020
@brownj85 brownj85 deleted the ch555-strawberry-fields-send-version-on-requests branch December 16, 2020 18:34
nquesada added a commit that referenced this pull request Jan 19, 2021
* Fix issue with single parameter list (#503)

* Fix issue with single parameter list

* Fix pyliny import complaint

* Update changelog

* removes unused variables in test_tdmprogram

* Fix run_options not being used (#500)

* Fix run_options not being used

* Update changelog

* Add tests

* removes unused variables in test_tdmprogram (#504)

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add program code generator function (#496)

* Add serialize function

* Run black

* Remove f

* Updates from code review

* Improve operations handling

* Remove duplicate line

* Fix generate_code + add tests

* Tidy things up a bit

* Add forgotten factor

* Run black

* Update changelog

* Fixes from code review

* Update strawberryfields/io.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* change argument name

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add wigner plotting (#495)

* Add wigner plotting to program

* Move plotting to plot module

* Remove numpy import

* Fixes after code-review

* Tidy up wigner plotting

* Run black

* Add test

* Update colours

* Update changelog

* rename tests

* Update strawberryfields/plot.py

Co-authored-by: antalszava <antalszava@gmail.com>

* add contours arg

* Update tests

* Update changelog

* Apply suggestions from code review

Co-authored-by: antalszava <antalszava@gmail.com>

* Remove url

* fix string

* fix arg name

Co-authored-by: antalszava <antalszava@gmail.com>

* Adds api_version property, adds 'Accept-Version' to headers (#512)

* Fock state and quadrature plotting  (#510)

* Fock state plotting draft

* Updates, error, test

* test & imports

* Test chart generation

* Formatting

* Remove unnecessary comment

* Two-mode test

* cutoff in test adjust

* quad and adjust fock prev chart

* Formatting

* Adjust

* quad test

* generate_quad_chart test

* Update tests/frontend/test_sf_plot.py

* update

* data always has two elements

* reset Makefile

* changelog, adjust chart title

* ket latex render

* latex in fock plot title

* adjust tests for latex

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* adjust

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* marginal

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* docstring

* adjust tests for Fock

* quad tests

* docstring

* Move obtaining the Wigner function of the state to generate_wigner_chart

* Docstring

* add plot page

* Update strawberryfields/plot.py

Co-authored-by: Theodor <theodor@xanadu.ai>

* base state render

* docstring basestate render change

Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Theodor <theodor@xanadu.ai>

* Fix bug in Dgate, Coherent, and DisplacedSqueezed (#507)

* Support TF tensors in batch form

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add test

* Add to changelog

* Update PR in changelog

* New line

* Extend to other gates

* Update changelog

* Update

* Update test

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Fix typo

* Fix

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update tdm docstring (#519)

* removes unused variables in test_tdmprogram

* updates docstring

* Implement OAuth refresh token flow (#520)

* Implement OAuth refresh token flow

* Apply suggestions from code review

Formatting changes

Co-authored-by: antalszava <antalszava@gmail.com>

* Add correct token refresh path

* update path, update getting the access token, remove url wrapping in _request

* Formatting with black

* move dict init into func

* Updates

* refresh access token unit tests

* no print

* User request.post directly, update tests

* Wrapped request test, updates

* Updates

* Formatting

* Remove access token refreshing from init

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update strawberryfields/api/connection.py

Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>

* update msg in test

* changelog

Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Antal Szava <antalszava@example.com>
Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>

* Increment version number to v0.17.0 (#523)

* bump version and update changelog

* update about

* remove old current release

* minor tweaks

* dev bump (#524)

* Update photonic_hardware.rst (#526)

Co-authored-by: Theodor <theodor@xanadu.ai>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Jack Brown <jack@xanadu.ai>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tim Leisti <corvust@users.noreply.github.com>
Co-authored-by: Antal Szava <antalszava@example.com>
Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>
nquesada added a commit that referenced this pull request Jan 20, 2021
* Fix issue with single parameter list (#503)

* Fix issue with single parameter list

* Fix pyliny import complaint

* Update changelog

* Fix run_options not being used (#500)

* Fix run_options not being used

* Update changelog

* Add tests

* removes unused variables in test_tdmprogram (#504)

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add program code generator function (#496)

* Add serialize function

* Run black

* Remove f

* Updates from code review

* Improve operations handling

* Remove duplicate line

* Fix generate_code + add tests

* Tidy things up a bit

* Add forgotten factor

* Run black

* Update changelog

* Fixes from code review

* Update strawberryfields/io.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* change argument name

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add wigner plotting (#495)

* Add wigner plotting to program

* Move plotting to plot module

* Remove numpy import

* Fixes after code-review

* Tidy up wigner plotting

* Run black

* Add test

* Update colours

* Update changelog

* rename tests

* Update strawberryfields/plot.py

Co-authored-by: antalszava <antalszava@gmail.com>

* add contours arg

* Update tests

* Update changelog

* Apply suggestions from code review

Co-authored-by: antalszava <antalszava@gmail.com>

* Remove url

* fix string

* fix arg name

Co-authored-by: antalszava <antalszava@gmail.com>

* Adds api_version property, adds 'Accept-Version' to headers (#512)

* Fock state and quadrature plotting  (#510)

* Fock state plotting draft

* Updates, error, test

* test & imports

* Test chart generation

* Formatting

* Remove unnecessary comment

* Two-mode test

* cutoff in test adjust

* quad and adjust fock prev chart

* Formatting

* Adjust

* quad test

* generate_quad_chart test

* Update tests/frontend/test_sf_plot.py

* update

* data always has two elements

* reset Makefile

* changelog, adjust chart title

* ket latex render

* latex in fock plot title

* adjust tests for latex

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* adjust

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* marginal

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update strawberryfields/plot.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* docstring

* adjust tests for Fock

* quad tests

* docstring

* Move obtaining the Wigner function of the state to generate_wigner_chart

* Docstring

* add plot page

* Update strawberryfields/plot.py

Co-authored-by: Theodor <theodor@xanadu.ai>

* base state render

* docstring basestate render change

Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Theodor <theodor@xanadu.ai>

* Fix bug in Dgate, Coherent, and DisplacedSqueezed (#507)

* Support TF tensors in batch form

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Add test

* Add to changelog

* Update PR in changelog

* New line

* Extend to other gates

* Update changelog

* Update

* Update test

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Fix typo

* Fix

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update tdm docstring (#519)

* removes unused variables in test_tdmprogram

* updates docstring

* Implement OAuth refresh token flow (#520)

* Implement OAuth refresh token flow

* Apply suggestions from code review

Formatting changes

Co-authored-by: antalszava <antalszava@gmail.com>

* Add correct token refresh path

* update path, update getting the access token, remove url wrapping in _request

* Formatting with black

* move dict init into func

* Updates

* refresh access token unit tests

* no print

* User request.post directly, update tests

* Wrapped request test, updates

* Updates

* Formatting

* Remove access token refreshing from init

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update tests/api/test_connection.py

* Update strawberryfields/api/connection.py

Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>

* update msg in test

* changelog

Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Antal Szava <antalszava@example.com>
Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>

* Increment version number to v0.17.0 (#523)

* bump version and update changelog

* update about

* remove old current release

* minor tweaks

* dev bump (#524)

* Update photonic_hardware.rst (#526)

* dummy change

* Update strawberryfields/backends/bosonicbackend/backend.py

Co-authored-by: Theodor <theodor@xanadu.ai>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Jack Brown <jack@xanadu.ai>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tim Leisti <corvust@users.noreply.github.com>
Co-authored-by: Antal Szava <antalszava@example.com>
Co-authored-by: Jeremy Swinarton <jeremy@swinarton.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants